package com.photovoltaic.auth.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * 密码加密工具类
 */
public class PasswordEncoder {
    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        String password = "123456";
        String encodedPassword = encoder.encode(password);
        System.out.println("原始密码: " + password);
        System.out.println("加密后的密码: " + encodedPassword);
        
        // 验证密码
        boolean matches = encoder.matches(password, encodedPassword);
        System.out.println("密码验证是否通过: " + matches);
        
        // 验证另一个已知的加密密码
        String existingEncodedPassword = "$2a$10$nCACOaBcG3MbGMLEbj6l/uzwO1oaKgP3/GvtlAguwS2I1JuKpqPDW";
        boolean matchesExisting = encoder.matches(password, existingEncodedPassword);
        System.out.println("已有加密密码验证是否通过: " + matchesExisting);
    }
} 